package com.boot.pojo;

import com.boot.util.Constants;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class Result {
    private int status;
    private String msg;
    private Map<String,Object> map = new HashMap<>();

    public Result() {
    }

    public Result(int status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public Result(int status, String msg, Map<String, Object> map) {
        this.status = status;
        this.msg = msg;
        this.map = map;
    }
    public Result add(String key,Object value){
        map.put(key,value);
        return this;
    }
    public Result success(){
        this.setStatus(Constants.CODE_100);
        return this;
    }
    public Result success(String message){
        this.setStatus(Constants.CODE_100);
        this.setMsg(message);
        return this;
    }
    public Result success(Map map){
        this.setStatus(Constants.CODE_100);
        this.setMap(map);
        return this;
    }
    public Result fail(String message){
        this.setStatus(Constants.CODE_200);
        this.setMsg(message);
        return this;
    }
}
